<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class PostModel extends Model
{
    //帖子信息
    protected $table = 'post';   //数据表
    protected $pk = 'post_id';  //主键

    protected $schema=[
        'post_id' => 'int',
        'user_id' => 'int',
        'post_title' => 'string',
        'post_content' => 'string',
        'post_category' => 'int',
        'post_label' => 'string',
        'post_img' => 'string',
        'post_ctr' => 'int',
        'post_check'=>'int',
        'post_time'=>'datetime'
    ];

    protected $createTime = 'post_time';

    public static function getAllPostInfo()
    {
        return PostModel::field('post_id,post_title,post_content,post_category,post_label,post_img,post_ctr')->select();
    }

    public static function getPostByPostId($post_id)
    {
        return PostModel::where('post_id',$post_id)->find();
    }
}
